﻿using AutoMapper;
using B.S.Data.MES.API.Applications.GenerateplanBasicApplication;
using B.S.Data.MES.API.Dto.GenerateIDto;
using B.S.Domain.Generateplan;
using B.S.Requst;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Data.MES.API.Controllers
{
    /// <summary>
    /// 生产计划Api
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class GenerateplanBasicController : ControllerBase
    {
        IMediator mediator;

        public GenerateplanBasicController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 生产计划显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIPageing<List<DtoGenerateplanBasic>>> ShowGenerateplanBasic([FromQuery]ShowGenerateplanBasicCommand request)
        {
           return await mediator.Send(request);
        }
        /// <summary>
        /// 添加生产计划
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIRequst<int>> AddGenerateplanBasic([FromBody]AddGenerateplanBasicCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 删除生产计划基本信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIRequst<int>> DeleteGenerateplanBasic([FromBody]DeleteGenerateplanBasicCommand request)
        {
            return  await mediator.Send(request);
        }
        /// <summary>
        /// 修改生产计划基本信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIRequst<int>> UpdateGenerateplanBasic([FromBody]UpdateGenerateplanBasicCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
